/// 帮助快速的把多个字段解析到指定字段上的辅助类
class SerializedUtils {
  /// 解析json
  static Map<String, dynamic> serialized(
      Map<String, dynamic> json, List<Rule> serializedRule) {
    for (Rule rule in serializedRule) {
      for (String from in rule.from) {
        if (json.containsKey(from)) {
          dynamic fromData = json.remove(from);
          json.putIfAbsent(rule.to, () => fromData);
        }
      }
    }
    return json;
  }
}

/// 解析规则
class Rule {
  String to;
  List<String> from;

  /// [to] 解析的目标字段，本地接收字段
  /// [from] 需要解析的字段，网络来的字段
  Rule({required this.to, required this.from});
}
